# Contributor: rubicon <rubicon@mailo.com>
# Maintainer:
pkgname=ocaml-bos
_pkgname=bos
pkgver=0.2.1
pkgrel=1
pkgdesc="Basic OS interaction for OCaml"
url="https://erratique.ch/software/bos"
arch="all !riscv64"  # limited by ocaml aport
license="ISC"
depends="
	ocaml-runtime
	ocaml-astring
	ocaml-fmt
	ocaml-fpath
	ocaml-logs
	ocaml-rresult
	"
depends_dev="
	$pkgname=$pkgver-r$pkgrel
	ocaml-astring-dev
	ocaml-fmt-dev
	ocaml-fpath-dev
	ocaml-logs-dev
	ocaml-rresult-dev
	"
makedepends="
	$depends_dev
	ocaml
	ocamlbuild
	ocaml-compiler-libs
	ocaml-findlib
	ocaml-topkg
	cmd:opam-installer
	"
checkdepends="ocaml-mtime-dev"
options="!check"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.bz2::https://erratique.ch/software/bos/releases/bos-$pkgver.tbz"
builddir="$srcdir/$_pkgname-$pkgver"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	ocaml pkg/pkg.ml build
}

package() {
	opam-installer -i \
		--prefix="$pkgdir"/usr \
		--libdir="$pkgdir/$_ocamldir" \
		--docdir="$builddir"/.omit \
		$_pkgname.install
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
8daeb8a4c2dd1f2460f6274ada19f4f1b6ebe875ff83a938c93418ce0e6bdb74b8afc5c9a7d410c1c9df2dad030e4fa276b6ed2da580639484e8b5bc92610b1d  ocaml-bos-0.2.1.tar.bz2
"
